#ifndef __GGEAR_POINT2_H
#define __GGEAR_POINT2_H

#include "ggear_types.h"
#include "ggear_math.h"

namespace ggear
{
	namespace gfx
	{
		template<class _Tx>
		struct Point2
		{
			//! Constructor
			Point2() : X(0), Y(0) {}

			
			//! Construct from specified coordinates
			Point2(_Tx _x, _Tx _y) : X(_x), Y(_y) {}

			
			//! Calculate distance between 2 points
			template<class _Ty>
			f64 Distance(const Point2<_Ty>& _pt) const
			{
				f64 dx = _pt.X - X;
				f64 dy = _pt.Y - Y;
				return glb::Math::Sqrt(dx*dx + dy*dy);
			}


			//! Multiply current point coordinates by a scalar
			template<class _Ty>
			friend Point2<_Tx> operator * (const Point2<_Tx>& _pt, _Ty _scalar)
			{
				return Point2<_Tx>(_pt.X * _scalar, _pt.Y * _scalar);
			}


			//! Check whether 2 are at the same position or not 
			template<class _Ty>
			friend bool operator == (const Point2<_Tx>& _lpt, const Point2<_Ty>& _rpt)
			{
				return (_lpt.X == _rpt.X) && (_lpt.Y == _rpt.Y);
			}

			
			//! Check if 2 points are different
			template<class _Ty>
			friend bool operator != (const Point2<_Tx>& _lpt, const Point2<_Ty>& _rpt)
			{
				return (_lpt.X != _rpt.X) || (_lpt.Y != _rpt.Y);
			}


			//! Properties
			union
			{
				struct
				{
					_Tx X;
					_Tx Y;
				};
				_Tx Coords[2];
			};
		};

		typedef Point2<u32> Point2u;

		typedef Point2<s32> Point2s;

		typedef Point2<f32> Point2f;

		typedef Point2<f64> Point2d;
	}
}

#endif